import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @ClassName MapDemo04
 * @Description 测试类
 * @Author Li
 * @Date 2022/8/6 9:06
 * @ModifyDate 2022/8/6 9:06
 * @Version 1.0
 */
public class MapDemo04 {
    public static void main(String[] args) {
        // 1.创建HashMap集合对象
        Map<Student, String> map = new HashMap<>();
        // 2.添加元素
        map.put(new Student("张三", 18), "北京");
        map.put(new Student("李四", 19), "上海");
        map.put(new Student("王二", 20), "广州");
        map.put(new Student("麻子", 18), "深圳");

        // 3.取出元素，遍历键
        Set<Student> keys = map.keySet();
        for (Student key : keys) {
            String value = map.get(key);
            System.out.println(key + "=" + value);
        }
    }
}
